# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :gather.py
# @Time      :2025/7/9 18:18
# @Author    :aiyimu

import asyncio

async def fetch_data(url, delay):
    print(f"开始获取 {url}")
    await asyncio.sleep(delay)
    print(f"完成获取 {url}")
    return f"{url} 数据"

async def main():
    # 同时启动多个任务
    results = await asyncio.gather(
        fetch_data("https://api1.com", 1.5),
        fetch_data("https://api2.com", 1.0),
        fetch_data("https://api3.com", 2.0)
    )
    print("所有数据: ", results)

asyncio.run(main())